#include "dirutils.h"
#include <QDir>
#include <QDirIterator>


QStringList DirUtils::songsInDir(QString dir) {
    QStringList sl;
    QDirIterator itr(dir, QStringList() << "*.mp3" << "*.flac",
          QDir::Files, QDirIterator::Subdirectories);
    while (itr.hasNext()) {
        QFileInfo fi(itr.next());
        sl << fi.absoluteFilePath();
    }

    return sl;

}

QStringList DirUtils::songFoldersInDir(QString dir) {
    QStringList sl;
    QDirIterator itr(dir, QStringList(), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories );
    while (itr.hasNext()) {
        QString path = itr.next();
        if (!songsInDir(path).isEmpty()) sl << path;
    }
    return sl;
}
